﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace SMP.Client.SystemForm
{
    using System.Collections;
    using SMP.Service;

    public partial class FrmLogin : DevExpress.XtraEditors.XtraForm
    {
        System_Service _objSystem = new System_Service();
        public FrmLogin()
        {
            InitializeComponent();
        }

        private void FrmLogin_Load(object sender, EventArgs e)
        {
            txtTaikhoan.EditValue = null;
            txtMatkhau.EditValue = null;
            txtTaikhoan.Focus();
        }

        private void btnDangnhap_Click(object sender, EventArgs e)
        {
            Hashtable hashtableControl = new Hashtable();
            hashtableControl.Add(txtTaikhoan, lbTaikhoan);
            hashtableControl.Add(txtMatkhau, lbMatkhau);
            if (!Windows.Utility.Validator.CheckNullFields(hashtableControl))
                return;

            var dtb = _objSystem.CheckLogin(txtTaikhoan.EditValue, txtMatkhau.EditValue);
            if (dtb == null || dtb.Rows.Count == 0)
            {
                Windows.Forms.Message.Show("Tài khoản hoặc mật khẩu không đúng", "Thông Báo");
                txtTaikhoan.Focus();
                FrmMain.check_login = false;
                return;
            }
            FrmMain.check_login = true;
            FrmMain.dtb_thanhvien = dtb.Copy();
            this.Close();
        }

        private void btnHuybo_Click(object sender, EventArgs e)
        {
            FrmMain.check_login = false;
            this.Close();
        }
    }
}